package org.example.shop.ware.controller;

import org.example.shop.entity.Ware;
import org.example.shop.ware.service.WareService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class WareController {

    @Resource
    private WareService wareService;

    @GetMapping("ware/{wid}")
    public ResponseEntity<Ware> find(@PathVariable Integer wid) {
        return ResponseEntity.ok(wareService.findByWid(wid));
    }

    @PostMapping("ware/add")
    public ResponseEntity<Ware> add(@RequestBody Ware ware) {
        return ResponseEntity.ok(wareService.save(ware));
    }
}
